import Vue from 'vue'
import VueRouter from 'vue-router'
// import UserInfo from '../views/Menus/User/UserInfo.vue'

// 因为下面使用了路由懒加载  这里就不需要导了
// import Login from '../views/login/login.vue'
// import Regging from '../views/regging/regging.vue'

Vue.use(VueRouter)

const routes = [

  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login/login.vue')
  },
  {
    path: '/ressing',
    name: 'regging',

    component: () => import('../views/ressing/ressing.vue')
  },
  {
    path: '/',
    name: 'main',
    component: () => import('../views/Main/Main.vue'),
    redirect: '/home',
    children: [
      // 二级路由的嵌套 二级利用path 不用加斜杠
      {
        path: 'home',
        name: 'home',
        component: () => import('../views/Menus/Home/Home.vue')
      },
      {
        path: 'user-info',
        name: 'UserInfo',
        component: () => import('../views/Menus/User/UserInfo.vue')
      },
      {
        path: 'user-avatar',
        name: 'UserAvatar',
        component: () => import('../views/Menus/User/UserAvatar.vue')
      },
      {
        path: 'user-pwd',
        name: 'UserPwd',
        component: () => import('../views/Menus/User/UserPwd.vue')
      }
    ]

  }
]

const router = new VueRouter({
  routes
})
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
export default router
